#include "Path.h"
#include "Transformations.h"
#include "Maths\Math.h"
#include "Maths\Random.h"


using namespace CasaEngine;


std::list<Vector2F> Path::CreateRandomPath(int   NumWaypoints,
                                           float MinX,
                                           float MinY,
                                           float MaxX,
                                           float MaxY)
{
    m_WayPoints.clear();

    float midX = (MaxX+MinX)/2.0;
    float midY = (MaxY+MinY)/2.0;

    float smaller = min(midX, midY);

    float spacing = MATH_2PI/(float)NumWaypoints;

    for (int i=0; i<NumWaypoints; ++i)
    {
      float RadialDist = RandInRange(smaller*0.2f, smaller);

      Vector2F temp(RadialDist, 0.0f);

      Vec2DRotateAroundOrigin(temp, i*spacing);

      temp.x += midX; temp.y += midY;
      
      m_WayPoints.push_back(temp);
                            
    }

    curWaypoint = m_WayPoints.begin();

    return m_WayPoints;
}


void Path::Render()const
{
  /*gdi->OrangePen();

  std::list<Vector2F>::const_iterator it = m_WayPoints.begin();

  Vector2F wp = *it++;

  while (it != m_WayPoints.end())
  {
    gdi->Line(wp, *it);

    wp = *it++;
  }

  if (m_bLooped) gdi->Line(*(--it), *m_WayPoints.begin());*/
}
